#include "baseframework.h"


BaseFrameWork::BaseFrameWork(QWidget *parent) :
    QWidget(parent){
    m_isPressed = false;
    m_areaMovable = this->geometry();
}


void BaseFrameWork::areaMovable(const QRect rect){
    if(m_areaMovable != rect){
        m_areaMovable = rect;
    }
}

void BaseFrameWork::mousePressEvent(QMouseEvent *event)
{   if(event->button() == Qt::LeftButton){
        m_point = event->pos();
        //判断m_point是否在点击的窗口范围内
        m_isPressed = m_areaMovable.contains(m_point);

    }

}

void BaseFrameWork::mouseMoveEvent(QMouseEvent *event)
{
    if(!m_isPressed){
        return;
    }
    this->move(this->pos() + event->pos() - m_point);

}

void BaseFrameWork::mouseReleaseEvent(QMouseEvent *)
{
    m_isPressed = false;
}


BaseFrameWork::~BaseFrameWork()
{
    // 析构函数

}
